package com.neusoft.util;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.neusoft.mapper.DeliveryAddressMapper;
import com.neusoft.po.DeliveryAddress;

/**
 * @author chj
 * @date 2024年9月6日
 */
/**
 * 在静态工具类中注入mapper的方式示例
 */
@Component
public class Lock {

	@Autowired
	private DeliveryAddressMapper deliveryAddressMapper;

	private static Lock Lock;

	@PostConstruct
	public void init() {
		Lock = this;
		Lock.deliveryAddressMapper = this.deliveryAddressMapper;

	}

	public static boolean AddressLock(DeliveryAddress deliveryAddresss) {
		String UserIn = deliveryAddresss.getUserId();
		Integer id = deliveryAddresss.getDaId();
		if (Lock.deliveryAddressMapper == null) {
			return false;
		}
		DeliveryAddress temp = Lock.deliveryAddressMapper.getDeliveryAddressById(id);
		if (temp == null) {
			return false;
		}
		String UserDB = temp.getUserId();
		return (UserDB == UserIn);
	}

	public static boolean EmptyLock(Integer num) {
		// 用于实现将密码单向加密后再存⼊数据库的功能。
		return num > 0;
	}
}
